# Contributor: Sören Tempel <soeren+alpinelinux@soeren-tempel.net>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=harfbuzz
pkgver=2.7.0
pkgrel=0
pkgdesc="Text shaping library"
url="https://freedesktop.org/wiki/Software/HarfBuzz"
arch="all"
license="MIT"
# tests depend on certain freetype behaviours
options="!check"
makedepends="freetype-dev glib-dev gobject-introspection-dev cairo-dev icu-dev
	graphite2-dev meson gtk-doc"
checkdepends="python3"
subpackages="$pkgname-static $pkgname-dev $pkgname-icu $pkgname-doc"
source="harfbuzz-$pkgname.tar.gz::https://github.com/harfbuzz/harfbuzz/archive/$pkgver.tar.gz"

build() {
	abuild-meson \
		--default-library=both \
		-Dglib=enabled \
		-Dgobject=enabled \
		-Dgraphite=enabled \
		-Dicu=enabled \
		-Dfreetype=enabled \
		-Dcairo=enabled \
		-Dgtk_doc=enabled \
		. output
	ninja -C output
}

check() {
	ninja -C output test
}

package() {
	DESTDIR="$pkgdir" ninja -C output install
}

static() {
	pkgdesc="$pkgdesc (static libraries)"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/*.a "$subpkgdir"/usr/lib/
}

dev() {
	default_dev
	mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
}

icu() {
	pkgdesc="Harfbuzz ICU support library"
	replaces="harfbuzz"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/lib*icu.so.* "$subpkgdir"/usr/lib/
}

sha512sums="65d5b9bd3a53be659dd7d220da220f6873f7246c2ab11205132998e4ac4245fcf51b6968e705b81cc7652db5bbacc90c8db977cf1020edf7957a626a19e055c0  harfbuzz-harfbuzz.tar.gz"
